// 标注工具类型
export type AnnotationType = 'rect' | 'arrow' | 'text' | 'mosaic' | 'number' | 'highlight' | 'pen' | 'eraser'

// 颜色选项
export const COLORS = {
  RED: '#FF0000',
  BLUE: '#0066FF',
  GREEN: '#00CC00',
  YELLOW: '#FFFF00',
  ORANGE: '#FF9900',
  PURPLE: '#9933FF',
  BLACK: '#000000',
  WHITE: '#FFFFFF',
} as const

// 线条粗细选项
export const LINE_WIDTHS = {
  THIN: 2,
  MEDIUM: 4,
  THICK: 6,
  EXTRA_THICK: 8,
} as const

// 基础点坐标
export interface Point {
  x: number
  y: number
}

// 矩形区域
export interface Rect {
  x: number
  y: number
  width: number
  height: number
}

// 标注配置
export interface AnnotationConfig {
  type: AnnotationType
  color: string
  lineWidth: number
  fontSize?: number
  text?: string
}

// 基础标注接口
export interface BaseAnnotation extends AnnotationConfig {
  id: string
  startPoint: Point
  endPoint?: Point
  points?: Point[] // 用于画笔工具
}

// 矩形标注
export interface RectAnnotation extends BaseAnnotation {
  type: 'rect'
  endPoint: Point
}

// 箭头标注
export interface ArrowAnnotation extends BaseAnnotation {
  type: 'arrow'
  endPoint: Point
}

// 文字标注
export interface TextAnnotation extends BaseAnnotation {
  type: 'text'
  text: string
  fontSize: number
}

// 马赛克标注
export interface MosaicAnnotation extends BaseAnnotation {
  type: 'mosaic'
  endPoint: Point
  mosaicSize: number
}

// 序号标注
export interface NumberAnnotation extends BaseAnnotation {
  type: 'number'
  number: number
  radius: number
}

// 高亮标注
export interface HighlightAnnotation extends BaseAnnotation {
  type: 'highlight'
  endPoint: Point
}

// 画笔标注
export interface PenAnnotation extends BaseAnnotation {
  type: 'pen'
  points: Point[]
}

// 橡皮擦标注
export interface EraserAnnotation extends BaseAnnotation {
  type: 'eraser'
  points: Point[]
  eraserWidth: number
}

// 所有标注类型的联合
export type Annotation =
  | RectAnnotation
  | ArrowAnnotation
  | TextAnnotation
  | MosaicAnnotation
  | NumberAnnotation
  | HighlightAnnotation
  | PenAnnotation
  | EraserAnnotation

// 编辑器状态
export interface EditorState {
  currentTool: AnnotationType | null
  currentColor: string
  currentLineWidth: number
  currentFontSize: number
  annotations: Annotation[]
  selectedAnnotationId: string | null
  isDrawing: boolean
  numberCount: number
}

// 历史记录项
export interface HistoryItem {
  id: string
  timestamp: number
  thumbnail: string
  filePath?: string
}

// OCR 识别结果
export interface OCRResult {
  text: string
  confidence: number
  words: Array<{
    text: string
    confidence: number
    bbox: {
      x0: number
      y0: number
      x1: number
      y1: number
    }
  }>
}




